﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WorkStation.Frameworks.EasyBus.Pipeline
{
    /// <summary>
    /// 执行上下文
    /// </summary>
    public class ActionContext
    {
        public static readonly string IGNORE_HANDLE_KEY = "ActionContext.Args.IgnoreHandle";

        private string _routeKey = string.Empty;

        /// <summary>
        /// 输入
        /// </summary>
        public object Input { get; set; }

        /// <summary>
        /// 是否继续
        /// </summary>
        public bool IsContinue { get; set; }

        /// <summary>
        /// 路由关键字（若没有设置，则用Input的FullName做RouteKey）
        /// </summary>
        public string RouteKey 
        {
            get 
            {
                if (this._routeKey == string.Empty)
                {
                    return this.Input.GetType().FullName;
                }
                else 
                {
                    return this._routeKey;
                }
            }
            set 
            {
                this._routeKey = value;
            }
        }

        /// <summary>
        /// 参数
        /// </summary>
        public Dictionary<string, object> Args { get; set; }

        public ActionContext()
        {
            this.IsContinue = true;

            this.Args = new Dictionary<string, object>();
            this.Args[IGNORE_HANDLE_KEY] = new List<string>();
        }
    }
}
